﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-weight:400; font-style:normal; "  bgcolor="#ffffff">
Version:0.9
StartHTML:0000000153
EndHTML:0000034359
StartFragment:0000000189
EndFragment:0000034323
SourceURL:https://tokmakov.msk.ru/blog/item/33
<html>
<body>
<!--StartFragment--><h1 style="margin: 15px 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); font-weight: normal; font-size: 25px; font-family: Arial, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Словари в Python</h1><div id="post-item" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(50, 50, 50); font-family: Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div style="margin: 15px 0px; padding: 0px; max-height: 1e+06px; overflow: hidden;"><p style="margin: 0px 0px 5px; padding: 0px; max-height: 1e+06px; font-size: 12px; color: rgb(150, 150, 150);">10.02.2018</p><p style="margin: 0px; padding: 0px; max-height: 1e+06px; font-size: 12px; color: rgb(150, 150, 150);">Теги:<span> </span><a href="https://tokmakov.msk.ru/blog/tags/20" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none; font-size: 12px;">Python</a><span> </span>•<span> </span><a href="https://tokmakov.msk.ru/blog/tags/139" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none; font-size: 12px;">Коллекция</a><span> </span>•<span> </span><a href="https://tokmakov.msk.ru/blog/tags/183" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none; font-size: 12px;">ТипыДанных</a></p></div><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Словарь — это ассоциативный массив или хеш. Это неупорядоченное множество пар ключ-значение с требованием уникальности ключей. Пара фигурных скобок<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">{}</code><span> </span>создает пустой словарь. В отличие от списка, доступ к элементам словаря производится по ключу, а не по индексу, ключ может быть любого типа.</p><h2 style="margin: 15px 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); font-weight: normal; font-size: 21px;">Примеры</h2><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Создание словаря</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">cat = {'name': 'Tom', 'species': 'cat', 'age': 3}</span><span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam = {}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam[2] = 'second'</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam[3] = 'third'</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam[1] = 'first'</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">{2: 'second', 3: 'third', 1: 'first'}<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Доступ к значениям по ключу</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">cat = {'name': 'Tom', 'spesies': 'cat', 'age': 3}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">cat['name']</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">'Tom'<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Методы<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">keys()</code>,<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">values()</code><span> </span>и<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">items()</code></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam = {'color': 'red', 'age': 42}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam.keys()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">dict_keys(['color', 'age'])</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam.values()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">dict_values(['red', 42])</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam.items()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">dict_items([('color', 'red'), ('age', 42)])<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Возвращаемые этими методами коллекции не являются истинными списками, однако эти типы данных (<code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">dict_keys</code>,<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">dict_values</code>,<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">dict_items</code>) можно использовать в цикле<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">for</code>.</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">spam <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">=</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">{</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 255);">'color'</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">:</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 255);">'red'</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">,</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 255);">'age'</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">:</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 255);">42</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(136, 136, 136);"># ключи</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">for</span> key <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">in</span> spam<span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">.</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 128, 192);">keys</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">(</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">)</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">:</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">    <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 128, 255);">print</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">(</span>key<span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">)</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(136, 136, 136);"># значения</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">for</span> value <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">in</span> spam<span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">.</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 128, 192);">value</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">(</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">)</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">:</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">    <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 128, 255);">print</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">(</span>value<span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">)</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(136, 136, 136);"># ключи и значения</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">for</span> key<span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">,</span> value <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">in</span> spam<span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">.</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 128, 192);">items</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">(</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">)</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">:</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">    <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 128, 255);">print</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">(</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 255);">'key='</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">,</span> key<span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">,</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 255);">', value='</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">,</span> value<span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">,</span> sep <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">=</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 255);">''</span><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(255, 0, 0);">)</span><span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Проверка существования ключа или значения в с помощью операторов<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">in</code><span> </span>и<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">not in</code>.</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users = {'ivanov@mail.ru' : 'Иванов', 'petrov@mail.ru' : 'Петров'}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">'ivanov@mail.ru' in users</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">True</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">'ivanov@mail.ru' in users.keys()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">True</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">'Иванов' in users.values()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">True</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">'Петров' not in users.values()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">False<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Метод<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">get(key [,default])</code><span> </span>возврвщает значение по ключу. Если ключ отсутствует в словаре, метод возвращает значение по умолчанию<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">default</code>.</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users = {'ivanov@mail.ru' : 'Иванов', 'petrov@mail.ru' : 'Петров'}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users.get('sidorov@mail.ru', 'Нет такого пользователя')</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">'Нет такого пользователя'<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Метод<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">setdefault(key [,default])</code><span> </span>возвращает значение ключа, но если его нет — создает ключ с значением<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">default</code>.</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users = {'ivanov@mail.ru' : 'Иванов', 'petrov@mail.ru' : 'Петров'}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">user = users.setdefault('sidorov@mail.ru', 'Сидоров')</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">user</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">'Сидоров'</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">{'ivanov@mail.ru': 'Иванов', 'petrov@mail.ru': 'Петров', 'sidorov@mail.ru': 'Сидоров'}<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Метод<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">pop(key [,default])</code><span> </span>удаляет ключ и возвращает значение; если ключа нет, возвращает<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">default</code>.</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users = {'ivanov@mail.ru' : 'Иванов', 'petrov@mail.ru' : 'Петров'}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users.pop('ivanov@mail.ru')</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">'Иванов'</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">{'petrov@mail.ru': 'Петров'}</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users.pop('sidorov@mail.ru', 'Сидоров')</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">'Сидоров'<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Метод<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">popitem()</code><span> </span>удаляет и возвращает кортеж (ключ, значение).</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users = {'ivanov@mail.ru': 'Иванов', 'petrov@mail.ru': 'Петров', 'sidorov@mail.ru': 'Сидоров'}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">for i in range(len(users)):</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">...</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">    user = users.popitem()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">...</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">    print(user)</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; background-color:#eff0f1; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">('sidorov@mail.ru', 'Сидоров')</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">('petrov@mail.ru', 'Петров')</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">('ivanov@mail.ru', 'Иванов')</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">{}<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Оператор<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">del</code><span> </span>удаляет пару по ключу.</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users = {'ivanov@mail.ru': 'Иванов', 'petrov@mail.ru': 'Петров'}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">del users['ivanov@mail.ru']</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">{'petrov@mail.ru': 'Петров'}<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Метод<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">copy()</code><span> </span>возвращает поверхностную копию словаря.</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">users = {'ivanov@mail.ru': 'Иванов', 'petrov@mail.ru': 'Петров'}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam = users.copy()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">{'ivanov@mail.ru': 'Иванов', 'petrov@mail.ru': 'Петров'}<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam = {1:[1,1], 2:[2,2]}</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">copy = spam.copy()</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam[1][0] = 3</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">spam</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">{1: [3, 1], 2: [2, 2]}</p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(170, 170, 170);">&gt;&gt;&gt;</span> <span style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(128, 0, 255);">copy</span></p><p style=" font-family:'Consolas'; background-color:#eff0f1; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">{1: [3, 1], 2: [2, 2]}<span class="copy" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(150, 150, 150); font-size: 8px; background: rgb(255, 255, 255); border: 0.5px solid rgb(209, 209, 209); border-radius: 5px; position: absolute; z-index: 1000; right: 1px; top: 1px; cursor: pointer; width: 60px; text-align: center;">Копировать</span></p><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; font-size:10px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p><p style="margin: 15px 0px; padding: 0px; max-height: 1e+06px;">Для создания глубокой копии, нужно использовать метод<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">deepcopy()</code><span> </span>модуля<span> </span><code style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(0, 0, 187);">copy</code>.</p><ul style="margin: 15px 0px 15px 35px; padding: 0px; max-height: 1e+06px;"><li style="margin: 0px; padding: 0px; max-height: 1e+06px;">Поверхностная копия создает новый составной объект (словарь или список), и затем вставляет в него ссылки на объекты, находящиеся в оригинале.</li><li style="margin: 0px; padding: 0px; max-height: 1e+06px;">Глубокая копия создает новый составной объект (словарь или список), и затем рекурсивно вставляет в него копии объектов, находящихся в оригинале.</li></ul><div class="liked-posts" style="margin: 25px 0px; padding: 17px 10px 10px; max-height: 1e+06px; font-size: 13px; color: rgb(100, 100, 100); border: 0.5px solid rgb(83, 144, 204); background: rgb(255, 255, 255); position: relative;"><ul style="margin: 1px 0px 0px 35px; padding: 0px; max-height: 1e+06px;"><li style="margin: 1px 0px 0px; padding: 0px; max-height: 1e+06px;"><a href="https://tokmakov.msk.ru/blog/item/32" style="margin: 1px 0px 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none;">Списки в Python</a></li><li style="margin: 0px; padding: 0px; max-height: 1e+06px;"><a href="https://tokmakov.msk.ru/blog/item/146" style="margin: 1px 0px 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none;">Дерево значений</a></li><li style="margin: 0px; padding: 0px; max-height: 1e+06px;"><a href="https://tokmakov.msk.ru/blog/item/113" style="margin: 1px 0px 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none;">Массивы в сценариях оболочки</a></li><li style="margin: 0px; padding: 0px; max-height: 1e+06px;"><a href="https://tokmakov.msk.ru/blog/item/105" style="margin: 1px 0px 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none;">Таблица значений</a></li><li style="margin: 0px; padding: 0px; max-height: 1e+06px;"><a href="https://tokmakov.msk.ru/blog/item/37" style="margin: 1px 0px 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none;">Строки в Python</a></li></ul></div><p class="post-keys" style="margin: 20px 0px 15px; padding: 0px; max-height: 1e+06px; font-size: 12px; color: rgb(150, 150, 150);">Поиск:<span> </span><a href="https://tokmakov.msk.ru/blog/search/query/Python" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none; font-size: 12px;">Python</a> •<span> </span><a href="https://tokmakov.msk.ru/blog/search/query/%D0%9A%D0%BE%D0%BB%D0%BB%D0%B5%D0%BA%D1%86%D0%B8%D1%8F" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none; font-size: 12px;">Коллекция</a> •<span> </span><a href="https://tokmakov.msk.ru/blog/search/query/%D0%A1%D0%BB%D0%BE%D0%B2%D0%B0%D1%80%D1%8C" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none; font-size: 12px;">Словарь</a> •<span> </span><a href="https://tokmakov.msk.ru/blog/search/query/%D0%A2%D0%B8%D0%BF%D1%8B%20%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D1%85" style="margin: 0px; padding: 0px; max-height: 1e+06px; color: rgb(83, 144, 204); text-decoration: none; font-size: 12px;">Типы данных</a></p></div><!--EndFragment-->
</body>
</html></body></html>